<div class="panel label5-form">
    <ul>
        <li>
            <label>省份：</label>
            <select name="province" title="请选择省份" required>
                <option value="">请选择省份</option>
            </select>
            城市：
            <select name="city" title="请选择城市" required>
                <option value="">请选择城市</option>
            </select>
        </li>
        <li>
            <label>运营商：</label>
            <select name="operator" title="请选择运营商" required>
                <option value="">请选择运营商</option>
                <option value="1">移动</option>
                <option value="2">联通</option>
                <option value="3">电信</option>
            </select>
        </li>
        <li>
            <label>归属地号段：</label>
            <select name="areaName" title="请选择归属地号段" required>
                <option value="">请选择归属地号段</option>
            </select>
        </li>
        <li>
            <label>&nbsp;</label>
            <input type="button" value="确定" onclick="submitform();"/>
        </li>
    </ul><br />
    <input type="hidden" id="pagsnp-checkhistory-url" value="{:AddonU('Task/check_history','startNo=varkey&tsid=vartsid')}" />
</div>
<script>
    function submitform() {
        var $areaName = $('select[name="areaName"]');
        if (!$areaName.val()) {
            alert('未选择号段!');
            return;
        }
        if ('undefined' == typeof (window.parent.set_startno)) {
            alert('未设置选择号段的方法!');
            return;
        }
        if ('undefined' != window.tsid) {
            var url = $('#pagsnp-checkhistory-url').val().replace('varkey', $areaName.val()+'0000').replace('vartsid', window.tsid);
            $.get(url, function (data) {
                if (data.count > 0) {
                    if (!confirm(data.msg)) {
                        return;
                    }
                }
                ajax_show_loading(false);
                window.parent.set_startno($areaName.val(), $areaName.find('option:selected').text(), window.alink);
                window.parent.close_startno_dialog(window.name);
            })
        } else {
            window.parent.set_startno($areaName.val(), $areaName.find('option:selected').text(), window.alink);
            window.parent.close_startno_dialog(window.name);
        }
    }
    // ajax_load_options('select[name="taskStrategyID"]', '?s=XCall/TaskStrategy/get_json/siteID/{$loginData.siteID}.html', '请选择任务策略', '{$data.taskStrategyID}');
    ajax_load_options('select[name="province"]', '?s=XCall/Task/get_province_json.html', '请选择省份', '{$data.province}');
    $('select[name="province"]').change(function () {
        var val = $(this).val();
        if (val != '请选择省份') {
            ajax_load_options('select[name="city"]', '?s=XCall/Task/get_city_json/province/' + val + '.html', '请选择城市', '{$data.city}');
        } else {
            $('select[name="city"]').html('<option>请选择城市</option>');
        }
    })
    $('select[name="city"]').change(function () {
        var val = $(this).val();
        if (!val)
            return;
        select_start_no();
    });
    $('select[name="operator"]').change(function () {
        var val = $(this).val();
        if (!val)
            return;
        select_start_no();
    });
    function select_start_no() {
        var province = $('select[name="province"]').val();
        var city = $('select[name="city"]').val();
        var isp = $('select[name="operator"]').val();
        isp = $('select[name="operator"]').find('option[value="' + isp + '"]').text();
        if (!province || !city || !isp) {
            return;
        }
        var areaName = province + city;
        if (province == '北京' || province == '上海' || province == '天津' || province == '重庆') {
            areaName = city;
        }
        var url = '?s=XCall/Task/get_startNo_list/areaname/' + areaName + '/isp/' + isp + '.html';
        // document.write(url);
        ajax_load_options('select[name="areaName"]', url, '请选择号码范围', '{$data.areaName}');
    }
    $('select[name="areaName"]').change(function () {
        return;
        var val = $(this).val();
        $('input[name="startNo"]').val(val + '0000');
        $('input[name="endNo"]').val('10000');
        var area = $(this).find('option:selected').text();
        $('input[name="name"]').val(area);
        area = area.substring(0, area.indexOf(' '));
    })
</script>